home *** CD-ROM | disk | FTP | other *** search
-
- InCampaign = false;
- CurrentLevel = 0;
-
- MaxLevelNum = 11;
-
- LevelFileList = {}
-
- -- Note: These are the campaign levels
- LevelFileList[1] = "Scripts/Campaign1Startup.lua";
- LevelFileList[2] = "Scripts/Campaign2Startup.lua";
- LevelFileList[3] = "Scripts/Campaign3Startup.lua";
- LevelFileList[4] = "Scripts/Campaign4Startup.lua";
- LevelFileList[5] = "Scripts/Campaign5Startup.lua";
- LevelFileList[6] = "Scripts/Campaign6Startup.lua";
- LevelFileList[7] = "Scripts/Campaign7Startup.lua";
- LevelFileList[8] = "Scripts/Campaign8Startup.lua";
- LevelFileList[9] = "Scripts/Campaign9Startup.lua";
- LevelFileList[10] = "Scripts/Campaign10Startup.lua";
-
- -- End with quickstart until we have limits:
- LevelFileList[MaxLevelNum] = "Scripts/QuickStartStartup.lua";
-
-
- -- Generic Level Start function
- function StartLevel( levelname )
-
- G.SetLoopingMusic( "Music/invasion_laxed.mp3");
-
- G.ActivateBackground( -1 );
- G.DestroyGroup("camera");
-
- if( not( MainMenu == nil ) and MainMenu.IsValid() ) then
- MainMenu.CloseWindow( "LevelChoiceWindow" );
- end
-
- G.LogicCreateLevel( levelname );
-
- G.SetPause( true );
- G.SetCursorActive( false );
- end
-
- function StartLevelCampaign( levelNumber )
- CurrentLevel = levelNumber
- InCampaign = true
-
- StartLevel( LevelFileList[CurrentLevel] )
- end
-
- ---------------------------------------------------------------------------
- -- In-Game Music Update function
- ---------------------------------------------------------------------------
-
- CurMusicLevel = 0
- function SwitchGameMusicLevel( newLevel )
-
- if( newLevel == CurMusicLevel ) then
- return
- end
-
- CurMusicLevel = newLevel
-
- if( CurMusicLevel == 2 ) then
- G.SwapFade("Music/invasion_maxed.mp3", 0.25 );
- elseif( CurMusicLevel == 1) then
- G.SwapFade("Music/invasion_haxed.ogg", 0.25 ); -- taxed.mp3 AKA haxed.ogg
- elseif( CurMusicLevel == 0) then
- G.SwapFade("Music/invasion_laxed.mp3", 0.25 );
- end
-
- end
-
- function UpdateGameMusic()
- -- Change music depending on tower level
- local tower = G.GetCogName("Tower");
- if( tower.IsValid() ) then
-
- local curTowerLevel = tower.GetTowerLevel()
-
- if( curTowerLevel <= 2 ) then
- SwitchGameMusicLevel( 2 )
- elseif( curTowerLevel <= 4 ) then
- SwitchGameMusicLevel( 1 )
- else
- SwitchGameMusicLevel( 0 )
- end
-
- end
- end
-
- ---------------------------------------------------------------------------
- -- Generic Level Exit function
- ---------------------------------------------------------------------------
- --[[
- function LevelExitDesc()
- if ( GameState == QuitLevel )then
- G.ActiveBackGround( 2 );
-
- TraitorTalk( "Hey where are you going!?!" )
-
- return "YOU QUIT!";
- elseif( GameState == Victory )then
- G.ActiveBackGround( 1 );
- return "YOU WON!";
- elseif( GameState == Defeat )then
- G.ActiveBackGround( 2 );
-
- TraitorTalk( "Oh no! The base, it's been invaded!" )
-
- return "YOU LOST!";
- end
- end
-
- ---------------------------------------------------------------------------
- -- Generic Level Update function
- ---------------------------------------------------------------------------
-
- -- Not really a victory check, this checks for defeat!
- function CheckLevelCompletion()
- local tower = G.GetCogName("Tower");
-
- if( not tower.IsValid() ) then
- G.SetGameState( Defeat );
- end
-
- if( not( GameState == InLevel ) ) then
- dofile( "Scripts/GameOver.lua" ); -- The gameover script should do all exit functionality:
- GMain["LevelUpdate"] = nil;
- end
- end
-
- function LevelUpdate()
-
- -- Make sure the player isn't trying to exit the level
- CheckLevelCompletion()
- UpdateGameMusic()
- -- This is the intro, where you check for level
- if( levelRoutine ) then
- local con, error = coroutine.resume( levelRoutine )
-
- -- Start the Level Sequence:
- if( con == false and GameState == InLevel ) then
- G.Mes( error )
- levelRoutine = coroutine.create( LevelSequence )
- end
- end
- end
- ]]--